#include "precompiled.h"
#include "header.h"

namespace Opl
{
	namespace Protocol
	{

		Header::Header(Opl::Core::EntityObject* parent)
			: Opl::Core::EntityObject(parent)
		{
		}

		Header::~Header()
		{
		}

		QDataStream& operator << (QDataStream& stream, const Header& msg)
		{
			stream << (quint8)msg.Type();
			stream << msg.Size();
			return stream;
		}

		QDataStream& operator >> (QDataStream& stream, Header& msg)
		{
			quint8 t;
			stream >> t;
			msg.setType((Header::ContainerType)t);
			quint32 sz;
			stream >> sz;
			msg.setSize(sz);
			return stream;
		}

		Header::Header(const Header& that)
		{
			(*this) = that;
		}

		Header& Header::operator=(const Header& that)
		{
			this->setType(that.Type());
			this->setSize(that.Size());
			return *this;
		}

		void Header::setSize(quint32 sz)
		{
			header.size = sz;
		}

		quint32 Header::Size()const
		{
			return header.size;
		}

		void Header::setType(ContainerType t)
		{
			header.type = t;
		}

		Header::ContainerType Header::Type()const
		{
			return header.type;
		}


	}
}